package cn.img;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class Img4 {
    public static void main(String[] args) throws Exception {
        var w = 600;
        var h = 600;
        var i = new BufferedImage(w, h, 2);
        var g = i.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);

        g.setColor(Color.BLACK);
        g.fillRect(0,0,w,h);

        //颜色对象
        var c1 = new Color(255, 255, 255);
        var c2 = Color.WHITE;
        var c3 = new Color(0xff, 0xff, 0, 0);//第四个参数为透明度 0完全透明 255不透明

        g.setColor(new Color(255, 0, 0, 100));
        g.fillOval(100,100,100,100);
        g.setColor(new Color(0, 255, 0, 100));
        g.fillOval(100,150,100,100);
        g.setColor(new Color(0, 0, 255, 100));
        g.fillOval(150,100,100,100);


        //字体对象
        g.setColor(new Color(255,255,0));
        //Font font = new Font("经典繁颜体",Font.BOLD,50);
        Font font = Font.createFont(Font.TRUETYPE_FONT,new File("fonts/c.ttf"));
        font = font.deriveFont(Font.PLAIN,35);


        g.setFont(font);
        g.drawString("中国人中文字符串效果郑州日本语",50,350);

        //font = new Font("Wingdings",Font.BOLD,60);
        //g.setFont(font);
        //g.drawString("T",50,480);


        g.dispose();
        ImageIO.write(i, "png", new File("i2.png"));
        Runtime.getRuntime().exec("cmd /k start i2.png");
    }
}
